#@layout()

#define main()
<div class="jfa-header-box" id="jfa-header-box">
	<div class="jfa-crumbs" id="jfa-crumbs">
		入口上线扫描
	</div>
	#include("/_view/common/_header_right.html")
</div>
<div class="jfa-content-box" id="jfa-content-box">
	<div class="jfa-content" id="jfa-content">
		<div id="toolbar" class="btn-group">
		
			<a class="btn btn-primary btn-sm margin-right-10" href="#" onclick="autoScanPage()">
				<i class="fa fa-barcode"></i>
				自动扫描枪触发
			</a>
			
			<a class="btn btn-primary btn-sm margin-right-10" href="#" onclick="manualScanPage()">
				<i class="fa fa-barcode"></i>
				手动扫描枪触发
			</a>
			
			<a class="btn btn-primary btn-sm margin-right-10" href="#" onclick="searchRack()">
				<i class="fa fa-refresh"></i>
				刷新
			</a>
			
	        <a class="btn btn-primary btn-sm" href="#(ctx)/admin/enterScan/add">
				<i class="fa fa-plus"></i>
				添加扫描记录
			</a>
	            
	    </div>
		<table id="rack">
			
		</table>
	</div>
</div>
<script type="text/javascript">
var datagridHeight=$("#jfa-content").height();
$('#rack').bootstrapTable({
    url: '#(ctx)/admin/enterScan/list',         
    method: 'get',
    toolbar: '#toolbar',
    striped: true,
    cache: false,
    pagination: true,
    sortable: false,                    
    sortOrder: "asc",  
    queryParams: function (params) {
        		var data = { 
		                pageSize: params.limit,
		                offset: params.offset
		            }
	            return data;
                },
    sidePagination: "server",
    pageNumber:1,
    toolbarAlign:"right",
    pageSize: 20,         
    pageList: [20, 40, 80, 100,200],
    search: false,
    strictSearch: true,
    showColumns: false,
    showRefresh: false,             
    minimumCountColumns: 2,
    clickToSelect: true,               
   	height: datagridHeight,
    uniqueId: "id",
    showToggle:false,
    cardView: false,
    detailView: false,
    columns: [
        {
            field: 'hanger_no',  title: '挂具编号'
        },  {
        	field: 'frame_no',  title: '电泳框编号'
        },  {
            field: 'trace_no',  title: '追溯编号'
        }, {
            field: 'barcode',  title: '条码'
        }, {
        	field: 'material_count',  title: '物料数量',formatter:materialCountFormatter
        }, {
            field: 'update_time',  title: '更新时间'
        }, {
            field: 'real_name',  title: '操作人'
        }, {
            field: 'employee_no',  title: '工号'
        },{
        	title: '操作',formatter:operaterFormatter
        }
    ],
    rowStyle: function (row, index) {
             if(row.hasOwnProperty("type")){
				 if(row.type==2){
					 return {css:{"background-color":"#98FB98"}}
				 }else{
				     return {css:{"background-color":"#F9F9F9"}}
				 }
             }
    }
});

function materialCountFormatter(value, row, index){
    if(value>-1){
      return value;
    }else{
      return '';
    }
}
function operaterFormatter(value, row, index){
	return "<a href='#(ctx)/admin/enterScan/edit?id="+row.id+"'>"+
	"<i class='fa fa-pencil' title='修改'></i>"+
	" </a> &nbsp"+
	'<a  href="#" onclick="deleteRack(\''+row.id+'\',\''+row.type+'\')">'+
	"	<i class='fa fa-trash' title='删除'></i>"+
	"</a>"
}

function deleteRack(id,type){
	layer.confirm("确认删除该记录？", {
		icon: 0
		, title:'' 
		, shade: 0.4
		, offset: "139px"
	}, function(index) { 
		$.ajax({
			url:"#(ctx)/admin/enterScan/delete",
			data:{"id":id,"type":type},
			dataType:"json",
			success:function(ret){
				$('#rack').bootstrapTable("refresh",{silent: true});
			    layer.msg(ret.msg);
			    layer.close(index);   
			},
			error:function(){
				layer.close(index);   
			}
		});                           
		                       
	});
}


function searchRack(){
	$('#rack').bootstrapTable("refresh");
    layer.msg('操作成功');
}

function manualScanPage(){
	layer.open({
        type: 2,
        maxmin:true,
        area: ['550px', '450px'],
        fixed: false, //不固定
        title:'手动扫描枪扫描测试',
        content: '#(ctx)/admin/enterScan/manualScanPage'
    });
}


function autoScanPage(){
	layer.open({
        type: 2,
        maxmin:true,
        area: ['550px', '450px'],
        fixed: false, //不固定
        title:'自动扫描枪扫描测试',
        content: '#(ctx)/admin/enterScan/autoScanPage'
    });
}
</script>
#end
 
 